package com.hyt.it.ogt.kq.main.controller.gov;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hyt.common.apiInfor.ApiResponse;
import com.hyt.it.ogt.kq.common.gov.constant.ResponseCode;
import com.hyt.it.ogt.kq.service.gov.model.param.TimeRoomPasswordParam;
import com.hyt.it.ogt.kq.service.gov.model.vo.TimeRoomPasswordVO;
import com.hyt.it.ogt.kq.service.gov.service.ITimeRoomPasswordService;
import com.hyt.model.PageParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSort;
import io.swagger.annotations.ApiSort;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 场次密码信息表 前端控制器
 * </p>
 *
 * @author huangyh
 * @since 2021-03-08
 */
@Api(tags = "111.场次密码", value = "场次密码")
@ApiSort(value = 111)
@RestController
@RequestMapping("/kw/gov/timeRoomPassword")
@Slf4j
public class TimeRoomPasswordController {

    @Resource
    private ITimeRoomPasswordService timeRoomPasswordService;

    @ApiOperation(
            value = "11.1 获取场次密码",
            notes = "30000:获取场次密码成功; 33401:获取场次密码异常;"
    )
    @ApiOperationSort(value = 1)
    @GetMapping("/getTimeRoomPassword")
    public ApiResponse<Object> getTimeRoomPassword(PageParam<TimeRoomPasswordVO> pageParam, TimeRoomPasswordParam param) {
        try {
            log.debug("# 查询场次密码分页数据参数 ： {}", param);
            Page<TimeRoomPasswordVO> page = timeRoomPasswordService.page(pageParam, param);
            return ApiResponse.builder()
                    .code(ResponseCode.SUCCESS.getCode())
                    .data(page)
                    .build();
        } catch (Exception e) {
            log.error("# 查询场次密码分页数据异常:", e);
            return ApiResponse.builder()
                    .code(ResponseCode.TIMES_PWD_QUERY_EXCEPTION.getCode())
                    .build();
        }
    }
}
